Declaration of a language element with partial address in ST

It is possible to define a not yet fully specified location (= a partial address) for the following language elements:

Syntax
TYPE
   name_1: STRUCT
      name_e1 AT %(I|Q|M)* (* optional_begin *) {OFFSET := value} (* optional_end *) : data-type := initial-value;
      name_e2 AT %(I|Q|M)* (* optional_begin *) {OFFSET := value} (* optional_end *) : data-type := initial-value;
      ...
   END_STRUCT (* optional_begin *) {SIZE := value} (* optional_end *);
END_TYPE
 
VAR | VAR_INPUT | VAR_OUTPUT | VAR_GLOBAL | VAR_TEMP
   name_3, name_4, ..., name_n1 AT %(I|Q|M)* : type := initial-value;              (* Here the variable 'name_n1' is defined with a partial address. *)
   name_5 AT %(I|Q|M)*, name_6 AT %(I|Q|M)*, ... name_n2 : type := initial-value;  (* Here the variables 'name_5' and 'name_6' are defined with a partial address. *)
   ...
END_VAR  
Meaning of the partial address and of the offset

Use AT %(I|Q|M)* to assign a partial address to the language element. The location will be specified at a later moment, e.g. in a tool to address the IOs or in a VAR_CONFIG section (for those variables that have been declared using the structure data type). Details: See "Declaring VAR_CONFIG sections within PLC-object".

AT %(I|Q|M)* is an optional specification for the language element. Without this specification, no partial address is defined for the language element. Enter a partial address according to this structure: 

 

Character

Meaning

1.

%

initiates the address

2.

prefix for location

defines the location

 

I

input

 

Q

output

 

M

memory

3.

*

not yet fully specified location
(replaces the prefix for the size and the integers as they are defined for a full physical address)

Enhancement to IEC-standard

As an enhancement to the →IEC-standard, it is possible to declare several variables with one partial address or several variables with partial addresses in one line.

Use the optional attribute OFFSET to define a relative bit offset after the address. This attribute is only supported for structure elements. Observe that the structure element with the highest end position + 1 is used for the size of the structured data type. A specified offset is also considered.
The below examples give you more insights into the impact of OFFSET onto the size of the structured data type.

Enhancement to IEC-standard

The attribute OFFSET is an enhancement to the IEC-standard as well.

The optional attribute SIZE for the bit size is only allowed for structured data types. Use this attribute to define the bits that will be copied between IO-segment and variable (see the example for a structured data type with different structure elements and the "SIZE" attribute in the following).
No matter whether a bit size or which bit size has been defined, observe that only the actual bits of the structure are copied. If the attribute SIZE specifies a smaller size, there is a message that the attribute is ignored. If the attribute SIZE specifies a larger size, the difference between the specified size and the actual size is skipped.

Restrictions

  • Neuron Power Engineer provides no validation of whether the locations are fully specified.

  • Neuron Power Engineer only conditionally checks the section of the variable for which the language element with the partial addresses is declared. It is possible to define partial addresses in the subsequently listed sections of variables and to even use such data types for all variables sections supported in Neuron Power Engineer. This is in contrast to the specification of the →IEC-standard (according to section "6.5.5.4 Directly represented variables – partly specified using “ * ”") that variables with partial addresses must not be used for →input variables or →in-out variables.

  • The definition of not yet fully specified locations has no impact on the execution of the application.

The declaration of partial addresses is possible within these sections:
(Consult the respective description of the section about possibly additional possibilities for the variable.)

Section

The declaration of the language element is done as:

VAR ... END_VAR

internal variable (see "Declaration of internal variables in ST")

VAR_INPUT ... END_VAR

input variable (see "Declaration of input variables in ST")

VAR_OUTPUT ... END_VAR

output variable (see "Declaration of output variables in ST")

VAR_GLOBAL ... END_VAR

global variable (see "Declaration of external variables in ST")

VAR_TEMP ... END_VAR

temporary variable (see "Declaration of temporary variables in ST")

TYPE ... END_TYPE(only for structure elements)

→structured data type (see "Declaration of a data type in ST")

A simple example with "OFFSET"
TYPE
  MyType1 : STRUCT
     Elem1 AT %I* : INT;                 (* assignment of a not yet fully specified input, no offset *)
     Elem2 AT %Q* {OFFSET := 9} : INT;   (* assignment of a not yet fully specified output, offset for 'elem2': 9 *)
     Elem3 : INT;                        (* no assignment of a location *)
  END_STRUCT;
END_TYPE
More complex examples with "OFFSET"
TYPE

  Motion_Out_DataSpeed_Type1 : STRUCT (* The size of the structured data type is: 41 bits *)

    Ready : BOOL; 

    S_Speed_4Byte AT %M* { OFFSET := 8} : SAFEDINT;

    S_Status_ErrStatus : SAFEBOOL; (* This structure element is placed at offset 40. *)

  END_STRUCT;

  Motion_Out_Type : STRUCT (* The size of the structured data type is: 42 bits *)

    DataSpeed : Motion_Out_DataSpeed_Type1;

    Error : BOOL; (* This structure element is placed at offset 41. *)

  END_STRUCT;

  Motion_3Axis_Out_Type : STRUCT (* The size of the structured data type is: 126 bits *)

  (* Without the offset for 'Motion_Out_DataSpeed_Type1', the size would be: 102 bits *)

    Axis : ARRAY [0..2] OF Motion_Out_Type;
  END_STRUCT;

  Motion_Out_DataSpeed_Type2 : STRUCT (* The size of the structured data type is: 28 bits *)

    Ready : BYTE;

    S_Byte AT %M* { OFFSET := 20} : BYTE;

    S_Bool AT %M* { OFFSET := 10} : BOOL;

    S_ByteNext : BYTE; (* This structure element is placed at offset 11. *)

  END_STRUCT;

  Motion_Out_DataSpeed_Type3 : STRUCT (* The size of the structured data type is: 33 bits *)

    Ready : BYTE;

    S_Byte AT %M* { OFFSET := 20} : BYTE;

    S_Bool AT %M* { OFFSET := 24} : BOOL;

    S_ByteNext : BYTE; (* This structure element is placed at offset 25. *)

  END_STRUCT;

  Motion_Out_DataSpeed_Type4 : STRUCT (* The size of the structured data type is: 88 bits *)

    Ready : BOOL;

    S_Byte AT %M* { OFFSET := 80} : BYTE;

    S_Status_ErrStatus AT %M* { OFFSET := 60} : SAFEBOOL;

    S_ByteNext : BYTE; (* This structure element is placed at offset 25. *)

  END_STRUCT;
END_TYPE
Example for a structured data type with different structure elements and the "SIZE" attribute
TYPE

  Motion_Out_DataSpeed_Type1_WS : STRUCT

    Ready : BOOL;

    S_Speed_4Byte AT %M* { OFFSET := 8} : SAFEDINT; (* assignment of a not yet fully specified memory and offset *)

    S_Status_ErrStatus : SAFEBOOL; (* This structure element is placed at offset 40. *)

  END_STRUCT {SIZE := 48};
END_TYPE